<?php
namespace App\Module\Admin\Request\News;

use App\Constants\Constant;
use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\Rule;

class CreateRequest extends FormRequest{

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'uri'=>'required|url',
            'title'=>'required',
            'content'=>'required_without:resources',
            'resources'=>'required_without:content|array',
            'resources.*'=>'url',
            'resource_type'=>['required_with:resources',Rule::in([Constant::RESOURCE_TYPE_PICTURE,Constant::RESOURCE_TYPE_VIDEO])]
        ];
    }
}